/************************************************************************/
/* guards                                                               */
/************************************************************************/
#ifndef CCANVAS_H
#define CCANVAS_H

#include <iostream>
#include <QtOpenGL>
#include <QGLWidget>
#include <QTimer>

#include "Base.h"
#include "World.h"
#include "AbstractRenderer.h"
#include "WRenderer.h"
#include "Player.h"
#include "InputEngine.h"
#include "Light.h"
#include <QGLViewer/qglviewer.h>

/************************************************************************/
/* Canvas to draw                                                       */
/************************************************************************/
//class CCanvas : public QGLWidget
class CCanvas : public QGLViewer
{
	Q_OBJECT
	
public:
	
	explicit CCanvas(QWidget *parent = 0) : QGLViewer(parent),tau(0.0)
	{
		QTimer *timer = new QTimer(this);
		connect(timer, SIGNAL(timeout()), this, SLOT(updateGL()));
		timer->start(10);
	};
	
protected:
	
	void init();
	void resizeGL(int width, int height);
	void draw();
	void keyPressEvent( QKeyEvent *e );
	void keyReleaseEvent ( QKeyEvent * event );
	void mousePressEvent (QMouseEvent *e);
	
//virtual void draw();

	void drawSkyBox();
	
private:

	
	// List of vertices and triangles
	//std::vector< Point3d > v;
	//struct Triangle { int v[3]; };
	//std::vector< Triangle > t;
	
	double tau;
	World _world;
	WRenderer _renderer;
	Player _player;
	Light * worldLight;
	
};
#endif 